using System;
using System.Drawing;
using System.Windows.Forms;

namespace demo
{
    public class ReferralNoteForm : Form
    {
        private Label lblMessage;
        private TextBox txtNote;
        private Button btnOk;
        private Button btnCancel;

        public string NoteText => txtNote.Text;

        public ReferralNoteForm(string message)
        {
            this.Text = "输入备注";
            this.StartPosition = FormStartPosition.CenterParent;
            this.Size = new Size(520, 240);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;

            lblMessage = new Label
            {
                AutoSize = false,
                Dock = DockStyle.Top,
                Height = 60,
                TextAlign = ContentAlignment.MiddleLeft,
                Padding = new Padding(10),
                Text = message ?? ""
            };

            txtNote = new TextBox
            {
                Dock = DockStyle.Top,
                Multiline = true,
                Height = 90,
                Margin = new Padding(10)
            };

            var panelButtons = new Panel
            {
                Dock = DockStyle.Bottom,
                Height = 50,
                Padding = new Padding(10)
            };

            btnOk = new Button
            {
                Text = "确定",
                DialogResult = DialogResult.OK,
                Width = 80,
                Height = 28
            };
            btnOk.Click += (s, e) => { this.DialogResult = DialogResult.OK; this.Close(); };

            btnCancel = new Button
            {
                Text = "取消",
                DialogResult = DialogResult.Cancel,
                Width = 80,
                Height = 28
            };
            btnCancel.Click += (s, e) => { this.DialogResult = DialogResult.Cancel; this.Close(); };

            // 布局按钮（右下角）
            btnCancel.Location = new Point(this.ClientSize.Width - 100, 10);
            btnOk.Location = new Point(this.ClientSize.Width - 190, 10);
            panelButtons.Controls.Add(btnCancel);
            panelButtons.Controls.Add(btnOk);

            this.Controls.Add(panelButtons);
            this.Controls.Add(txtNote);
            this.Controls.Add(lblMessage);
        }
    }
}